package com.lk.sys.common.aspect;

import lombok.extern.log4j.Log4j;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

@Slf4j
@Aspect
@Component
public class SysTimeAspect {

    @Pointcut("bean(sysUserServiceImpl)")
    public void doTimePointCut(){}

    @Before("doTimePointCut()")
    public void doBefore(){
        System.out.println("@Before");//4
    }
    @After("doTimePointCut()")
    public void doAfter(){
        System.out.println("@After");//5
    }
    @AfterReturning("doTimePointCut()")
    public void AfterReturning(){
        System.out.println("@AfterReturning");//6
    }
    @AfterThrowing("doTimePointCut()")
    public void AfterThrowing(){
        System.out.println("@AfterThrowing");//6
    }

    @Around("doTimePointCut()")
    public Object doAround(ProceedingJoinPoint joinPoint) throws Throwable {
        System.out.println("around.before");//1
        try {
            Object result = joinPoint.proceed();//2
            System.out.println("around.after");//3
            return result;
        } catch (Throwable throwable) {
            System.out.println("around.exception");
            throw throwable;
        }
    }


}
